  
<?php 
    header('Access-Control-Allow-Origin: *'); 
?>
        
<?php

//require
require 'libs/vendor/autoload.php';
require 'routers/Router.php';
require 'models/databaseHandler.php';
require 'controllers/Controller.php';
require 'controllers/AuthController.php';
require 'controllers/UserController.php';
require 'controllers/ArticleController.php';
require 'controllers/CategorieController.php';
require 'controllers/MessageController.php';
require 'controllers/WishListController.php';


//Load Slim
$app = new \Slim\Slim();
//Authentificate Function
\Slim\Slim::getInstance();
// User id from db - Global Variable
$app->user_id = NULL;
//User email from db Global Variable
$app->user_email = "";
//call database class
$app->myDB = new DatabaseHandler();
//Authen init
$app->authen = new AuthController($app);
//init the router
$router = new Router($app);

// Router
//Users
$router->get('/user/:email', 'UserController/getUser');
$router->get('/users', 'UserController/getUsers');
$router->post('/register', 'UserController/addUser');
$router->post('/login', 'UserController/loginUser');
//Articles
$router->post('/article', 'ArticleController/addArticle');
$router->get('/article', 'ArticleController/getArticles');
$router->get('/articles', 'ArticleController/getAllArticles');
$router->get('/articleCat/:categorie_Id', 'ArticleController/getArticleByCat');
$router->get('/article/:article_Id', 'ArticleController/getArticle');
$router->put('/article/:article_Id', 'ArticleController/editArticle');
$router->delete('/article/:article_Id', 'ArticleController/deleteArticle');
//Categories
$router->post('/categorie', 'CategorieController/addCategorie');
$router->get('/categorie', 'CategorieController/getCategories');
$router->get('/categorie/:categorie_Id', 'CategorieController/getCategorie');
$router->put('/categorie/:categorie_Id', 'CategorieController/editCategorie');
$router->delete('/categorie/:categorie_Id', 'CategorieController/deleteCategorie');
//Message
$router->post('/message/:article_Id', 'MessageController/sendMessage');
$router->get('/messages', 'MessageController/getAllMessage');
$router->get('/message/:message_Id', 'MessageController/getMessage');
$router->delete('/message/:message_Id', 'MessageController/deleteMessage');
//Wish List
$router->post('/wishlist', 'WishListController/addWish');
$router->get('/wishlist', 'WishListController/getWish');
$router->get('/wishlists', 'WishListController/getAllWish');
$router->delete('/wishlist/:wish_Id', 'WishListController/deleteWish');

$app->run();
   
?>
